<!--
 * @Author: your name
 * @Date: 2020-11-12 09:17:40
 * @LastEditTime: 2021-05-12 11:26:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \purchase-zhqh\src\views\settlement\engineerSettlementCheck.vue
-->
<template>
  <a-card>
    <div style="margin-top: 10px" :bordered="false">
      <a-tabs default-active-key="1" @change="callback" class="nav_active">
        <!-- 加载的组件  -->
        <!-- 待办任务 tab -->
        <a-tab-pane key="1" tab="待办任务">
          <waitTask
            :FlowName="FlowName"
            ref="waitingTask"
            @send-record="checkHandle"
          ></waitTask>
        </a-tab-pane>

        <!-- 已办任务 tab -->
        <a-tab-pane key="2" tab="已办任务">
          <!-- 已办任务 组件 -->
          <finishTask
            :FlowName="FlowName"
            ref="finishingTask"
            @send-record="finishCheck"
          ></finishTask>
        </a-tab-pane>
      </a-tabs>

      <a-modal v-model="dialogVisible" width="80%">
        <!-- Modal 页脚按钮 -->
        <template slot="footer">
          <!-- 所有的按钮 -->
          <modalBar
            :duty_name="duty_name"
            :tabKey="tabKey"
            :nextTaskarray="nextTaskarray"
            :assigneeArray="ASSIGNEE_array"
            :nextStepType="next_step_type"
            @send-task="sendTask"
            @close-modal="closeModal"
            @end-task="endTask"
          ></modalBar>
        </template>

        <!-- Modal 对话框内容 -->
        <div id="printTest">
          <a-divider>备货通知申请</a-divider>

          <a-descriptions
            title
            bordered
            :column="{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 1, xs: 1 }"
            style="text-align: right"
          >
            <a-descriptions-item label="单据号">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.requisitionNo }}</span>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="单据日期">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.applicationDate }}</span>
              </div>
            </a-descriptions-item>

            <a-descriptions-item label="申请部门">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.department }}</span>
              </div>
            </a-descriptions-item>
            <a-descriptions-item label="申请人">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.applicant }}</span>
              </div>
            </a-descriptions-item>
            <!-- <a-descriptions-item label="业务员">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.salesman }}</span>
              </div>
            </a-descriptions-item> -->

            <a-descriptions-item label="客户">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.kehu }}</span>
              </div>
            </a-descriptions-item>

            <a-descriptions-item label="备注">
              <div style="text-align: left">
                <span style="border: 0">{{ Form.remarks }}</span>
              </div>
            </a-descriptions-item>

            <!-- 备注 -->
            <!-- <a-descriptions-item label="备注" :span="3">
              <div>
                <a-textarea
                  v-model="Form.remarks"
                  style="background-color: white; color: black"
                  :auto-size="{ minRows: 2 }"
                />
              </div>
              <div style="margin-top: 10px; text-align: left">
                <a-row>
                  <a-col :span="9"></a-col>
                  <a-col :span="9">
                    签名：
                    <span>{{ applicantName }}</span>
                  </a-col>
                  <a-col :span="6">日期：{{ applicantDate }}</a-col>
                </a-row>
              </div>
            </a-descriptions-item> -->
          </a-descriptions>

          <a-table
            :columns="columns"
            :data-source="dataSource"
            style="margin-top: 10px"
            :pagination="false"
          >
            <span
              slot="actualQuantity"
              slot-scope="text, record"
              label="实发数量"
            >
              <a-input-number
                v-if="ShiFaShuLiang"
                v-model="record.actualQuantity"
                :min="0"
                :precision="3"
              />
              <span v-if="!ShiFaShuLiang">{{ record.actualQuantity }}</span>
            </span>
            <!-- <template slot="actualQuantity" slot-scope="text, record">
              <a-input-number
                v-if="ShiFaShuLiang"
                v-model="record.actualQuantity"
                :min="0"
                :precision="3"
              ></a-input-number> </template
          > -->
          </a-table>

          <a-divider>流程审批意见</a-divider>
          <!--  动态生成工作流填入意见  -->
          <a-descriptions
            title
            bordered
            :column="{ xxl: 3, xl: 3, lg: 3, md: 3, sm: 1, xs: 1 }"
            style="text-align: right"
            size="small"
          >
            <a-descriptions-item
              v-for="(item, index) in workForm"
              :key="index"
              :label="item.label"
              :span="3"
              style="width: 200px"
            >
              <div>
                <a-textarea
                  v-model="item.desc"
                  :disabled="
                    duty_name == workflow_Array[index] && tabKey == 1
                      ? false
                      : true
                  "
                  style="background-color: white; color: black; width: 100%"
                  :auto-size="{ minRows: 2 }"
                />
              </div>
              <div style="margin-top: 10px; text-align: left">
                <a-row>
                  <a-col :span="9">
                    <a-radio-group
                      v-model="item.radio_value"
                      @change="radio_Change(index)"
                    >
                      <a-radio
                        style="margin-left: 5px"
                        :value="1"
                        :disabled="
                          duty_name == workflow_Array[index] && tabKey == 1
                            ? false
                            : true
                        "
                      >
                        同意
                      </a-radio>
                      <a-radio
                        :value="2"
                        :disabled="
                          duty_name == workflow_Array[index] && tabKey == 1
                            ? false
                            : true
                        "
                      >
                        不同意
                      </a-radio>
                    </a-radio-group>
                  </a-col>
                  <a-col :span="9">
                    签名：
                    <img
                      v-if="!item.signImg"
                      :src="item.sign"
                      style="width: 100px; height: 30px"
                    />
                    <span v-if="item.signImg">{{ item.sign }}</span>
                  </a-col>
                  <a-col :span="6">日期：{{ item.date }}</a-col>
                </a-row>
              </div>
            </a-descriptions-item>
          </a-descriptions>
        </div>
      </a-modal>
    </div>
  </a-card>
</template>

<script>
// 加载 工作流变动接口
import { workflowHttp } from "../../services/modules/workFlow";
const wfHttp = new workflowHttp();

// 已办任务组件
import waitTask from "../../components/common/waitTask";

// 已办任务组件
import finishTask from "../../components/common/finishTask";

// 按钮组件
import modalBar from "../../components/common/modalBar";

const columns = [
  {
    title: "序号",
    dataIndex: "key",
    key: "key",
    align: "center",
  },
  // {
  //   title: "仓库编码",
  //   key: "depotNo",
  //   dataIndex: "depotNo",
  //   align: "center",
  // },
  // {
  //   title: "仓库名称",
  //   key: "depotName",
  //   dataIndex: "depotName",
  //   align: "center",
  // },
  // {
  //   title: "所属单位",
  //   key: "storageUnit",
  //   dataIndex: "storageUnit",
  //   align: "center",
  // },
  {
    title: "存货编码",
    dataIndex: "inventorNo",
    key: "inventorNo",
    align: "center",
  },
  {
    title: "存货名称",
    dataIndex: "inventorName",
    key: "inventorName",
    align: "center",
  },
  {
    title: "规格型号",
    dataIndex: "standardModel",
    key: "standardModel",
    align: "center",
  },
  {
    title: "单位",
    key: "unit",
    dataIndex: "unit",
    align: "center",
  },
  // {
  //   title: "辅助单位",
  //   key: "auxiliaryUnit",
  //   dataIndex: "auxiliaryUnit",
  //   align: "center",
  // },
  {
    title: "申请数量",
    dataIndex: "applyNumber",
    key: "applyNumber",
    align: "center",
  },
  {
    title: "实发数量",
    dataIndex: "actualQuantity",
    key: "actualQuantity",
    align: "center",
    scopedSlots: { customRender: "actualQuantity" },
  },
  {
    title: "包装形式",
    key: "postType",
    dataIndex: "postType",
    align: "center",
  },

  {
    title: "发货时间",
    key: "deliveryTime",
    dataIndex: "deliveryTime",
    align: "center",
  },

  {
    title: "源单号",
    key: "sourceNumber",
    dataIndex: "sourceNumber",
    align: "center",
  },
  {
    title: "是否赠品",
    key: "isGiveAway",
    dataIndex: "isGiveAway",
    align: "center",
  },

  // {
  //   title: "备注",
  //   key: "remarks",
  //   dataIndex: "remarks",
  //   align: "center",
  // },
];

export default {
  components: {
    waitTask,
    finishTask,
    modalBar,
  },
  data() {
    return {
      ShiFaShuLiang: false, //实发数量插槽
      // ------------ 工作流传递参数 ----------------

      // 申请人数据
      Form: {
        requisitionNo: "", // 申请单号
        applicationDate: "", // 申请日期
        applicant: "", // 申请人
        depotName: "", // 仓库名称
        storageUnit: "", // 所属单位
        department: "", //申请部门
        ApplyUser: "", //申请人
        salesman: "", //业务员
        kehu: "", //客户
        remarks: "", //备注
      },

      applicantName: "", // 申请人姓名
      applicantDate: "", //  申请人日期

      workForm: [], // 工作流数据

      Label: ["备货组意见", "销售调度人员", "仓库管理员"],

      columns,
      dataSource: [],

      // ------ 工作流产生数据 ------------

      tabKey: 1, // 全局 tab Key

      dialogVisible: false, // 办理 modal 显示

      // ------ 工作流通用数据
      FlowName: "备货流程", // 流程名称
      duty_name: "", // 当前任务进程名称
      workflow_Array: [], // 工作流数组，记录了当前工作流的所有流程步骤
      storeId: "", // 存储 任务ID ，待办任务中，提交按钮 需要提交任务ID
      TableItemID_: [], //已办-表格-一条数据的id

      ACT_ID: "", //!修改审批的流程ID
      updateArr: [], //!修改数据的数组
      // ------ 传递到 modalBar 组件的数据
      nextTaskarray: [], // 下一级任务节点数组
      ASSIGNEE_array: [], // 办理人数组
      next_step_type: "", // 用来控制下一步任务是单选还是多选,下一步任务办理人是单选还是多选
    };
  },
  computed: {},
  mounted() {
    this.getDutyInfo();
  },
  methods: {
    // ---------- 工作流方法 ----------

    // tab 标签页 的回调函数
    callback(key) {
      if (key === "1") {
        // 待办任务列表
        this.tabKey = 1;
        // 刷新代办任务列表
        this.checkData = [];
        this.refreshCheckTask();
      } else if (key === "2") {
        // 已办任务列表
        this.tabKey = 2;
        this.finishData = [];
        // this.refreshFinishTask();
        // 刷新已办任务列表
      }
    },

    // 根据当前流程渲染表单,用来控制工作流程中哪一部分可以填写
    getDutyInfo() {
      // this.FlowName
      let query_name = "?name=" + this.FlowName;
      console.log("查询路径", query_name);
      wfHttp.getProcessstepByFlowName(query_name).then((res) => {
        console.log("工作流程步骤信息:::", res);
        this.workflow_Array = [];
        this.workflow_Array.push(res.result.firstTask);
        let array = res.result.processStep.split(",");
        for (let i = 0; i < array.length; i++) {
          this.workflow_Array.push(array[i]);
        }
        console.log("this.workflow_Array=====>", this.workflow_Array);
        this.workForm = [];
        for (let i = 0; i < this.workflow_Array.length; i++) {
          let data = {
            desc: "", // 描述框
            signImg: "true",
            sign: "",
            date: "",
            label: this.Label[i], // 标签
            radio_value: "",
          };
          this.workForm.push(data);
        }
        console.log("工作流程步骤信息:::", this.workForm);
      });
    },

    //------------- 电子签名处理函数 -------------------

    getSignImg(data) {
      let signImg = "";
      if (data == null || data == "") {
        signImg = true;
      } else {
        signImg = false;
      }
      return signImg;
    },

    // 根据 电子签名显示标识 来控制如何显示,sign 是渲染的签名，
    // signImg 签名如何显示控制器，sign_name 申请人姓名，sign_Img申请人电子签名
    showSignImg(signImg, sign_name, sign_Img) {
      var sign = "";
      if (signImg == true) {
        sign = sign_name;
      } else {
        sign = sign_Img;
      }
      return sign;
    },
    // 单选按钮触发事件
    radio_Change(index) {
      console.log(this.workForm[index]);
      if (this.workForm[index].radio_value == 1) {
        this.workForm[index].desc = "同意";
      } else {
        this.workForm[index].desc = "不同意";
      }
    },
    // -------------- tab 1 待办任务 ----------------------
    // 重新刷新待办任务列表
    refreshCheckTask() {
      this.$refs.waitingTask.postTasksList();
    },

    // 待办任务组件触发函数, 点击办理按钮触发
    checkHandle(record) {
      console.log("record", record);
      this.ShiFaShuLiang = false;
      if (record.TASK_DEF_KEY_ == "StockUT4") {
        //"仓库管理员审批"
        this.ShiFaShuLiang = true; //实发数量审批插槽
      } else {
        this.ShiFaShuLiang = false; //实发数量审批插槽
      }

      // console.log("显示时哪个任务+++++++++++++", this.tabKey);
      console.log("待办任务列表中的一条数据+++++++++++++", record);
      this.getDutyInfo();
      this.ASSIGNEE_Key = [];
      let PROC_INST_ID_ = record.PROC_INST_ID_; // 实例流程ID
      this.storeId = record.ID_;
      let FILENAME = record.FILENAME;
      let singleFormData = new FormData();

      singleFormData.append("PROC_INST_ID_", PROC_INST_ID_);
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("FILENAME", FILENAME);

      // 待办任务
      wfHttp.postProcessInformation(singleFormData).then((res) => {
        console.log("返回的总体工作流数据+++++++++++", res);

        this.duty_name = res.result.currentTask; // 获取当前的任务
        console.log("当前任务名称:::", this.duty_name);

        this.nextTaskarray = []; // 重置下一步任务列表
        this.ASSIGNEE_array = []; // 重置下一步办理人列表

        // 解析下一步任务数组、解析下一步人员数组
        for (let i = 0; i < res.result.nextUserNameList.length; i++) {
          this.nextTaskarray.push(res.result.nextUserNameList[i].taskName); // 下一步任务数组

          // 下一步人员信息
          let keysArray = Object.keys(
            res.result.nextUserNameList[i].userNameAndId
          );
          // console.log("获取所有用户id:::::", keysArray);

          for (let j = 0; j < keysArray.length; j++) {
            // 包含 key 值
            // console.log(keysArray[j]);
            // console.log(this.ASSIGNEE_Key.indexOf(keysArray[j]) == -1);

            if (this.ASSIGNEE_Key.indexOf(keysArray[j]) == -1) {
              let data = {
                userId: keysArray[j],
                userName:
                  res.result.nextUserNameList[i].userNameAndId[keysArray[j]],
              };
              // console.log("用户数据::::", data);
              this.ASSIGNEE_array.push(data);
              this.ASSIGNEE_Key.push(keysArray[j]);
            }
          }
        }
        // console.log("下一步任务数组:::", this.nextTaskarray);
        // console.log("下一步人员信息:::", this.ASSIGNEE_array);

        let varList = res.result.varList; // 申请人提交的数据
        let hitaskList = res.result.hitaskList; // 工作流产生数据
        console.log("申请人提交数据:::", varList);
        console.log("工作流产生数据:::", hitaskList);

        // --------- 申请人数据 ---------------
        this.Form = {
          requisitionNo: varList[0].TEXT_, //申请单号
          depotName: varList[1].TEXT_, //仓库名称
          department: varList[2].TEXT_, //申请部门
          applicant: varList[5].TEXT_, //申请人
          kehu: varList[6].TEXT_, //客户
          salesman: varList[7].TEXT_, //业务员
          remarks: varList[8].TEXT_, //备注
          applicationDate: varList[12].TEXT_, //申请日期
        };
        this.dataSource = [];
        for (let m = 14, n = 1; m < varList.length; m++, n++) {
          this.TableItemID_[n - 1] = varList[m].ID_; //表格中一条数据id
          console.log(
            "this.TableItemID_[m] = varList[i].ID_;",
            this.TableItemID_[m]
          );
          let array = [];
          array = varList[m].TEXT_.split(";"); //生产领料单的内容
          console.log("array=====================>", array);
          let dataSource1 = {
            key: n,
            id: array[0], // 备货通知主键id
            depotNo: array[1], // 仓库编码
            depotName: array[2], // 仓库名称
            storageUnit: array[3], // 存储单位
            inventorNo: array[4], // 存货编码
            inventorName: array[5], // 存货名称
            unit: array[7], // 单位
            auxiliaryUnit: array[8], // 辅助单位
            applyNumber: array[9], // 申请数量
            actualQuantity: array[9], // 实发数量
            postType: array[11], // 包装形式
            deliveryTime: array[12], // 发货时间
            sourceNumber: array[13], // 源单号
            isGiveAway: array[14], // 是否赠品
            remarks: array[15], // 备注
          };

          if (array[6] != "null") {
            dataSource1[`standardModel`] = array[6];
          } else {
            dataSource1[`standardModel`] = "";
          }
          if (array[8] != "null") {
            dataSource1[`auxiliaryUnit`] = array[8];
          } else {
            dataSource1[`auxiliaryUnit`] = "";
          }
          // if (array[10] != "null") {
          //   dataSource1[`actualQuantity`] = array[10];
          // } else {
          //   dataSource1[`actualQuantity`] = 0;
          // }

          this.dataSource.push(dataSource1);
        }
        console.log("123123", this.dataSource);
        // 更新数组
        this.updateArr = [];
        // for (let i = 10, k = 0; i < varList.length; i++, k++) {
        //   let data2 = {
        //     id_: varList[i].ID_, //更新记录ID
        //     warehouseStockNotificationContentEntity: {}, //备货通知单修改对象
        //     text_: varList[i].TEXT_, //更新记录内容
        //   };

        //   data2.warehouseStockNotificationContentEntity = {
        //     actualQuantity: parseInt(this.dataSource[k].actualQuantity),
        //     id: parseInt(this.dataSource[k].id),
        //   };
        //   this.updateArr.push(data2);
        // }
        console.log("需要更新的数据==============》", this.updateArr);

        this.ACT_ID = hitaskList[hitaskList.length - 1].ACT_ID_;
        console.log("ACT_ID============", this.ACT_ID);
        this.applicantName = hitaskList[1].ASSIGNEE_;
        this.applicantDate = hitaskList[1].START_TIME_;

        // --------- 工作流数据 ---------------
        // 利用for 循环来渲染数据,渲染的数据是目前已经完成的任务

        for (let j = 0; j < hitaskList.length; j++) {
          for (let i = 0; i < this.workflow_Array.length; i++) {
            if (hitaskList[j].ACT_NAME_ == this.workflow_Array[i]) {
              console.log(hitaskList[j].ACT_NAME_);
              this.workForm[i].desc = hitaskList[j].TEXT_; // 下一个描述
              if (hitaskList[j].END_TIME_ != null) {
                this.workForm[i].date = hitaskList[j].END_TIME_.substring(
                  0,
                  10
                );
                this.workForm[i].signImg = this.getSignImg(hitaskList[j].eUrl);
                this.workForm[i].sign = this.showSignImg(
                  this.workForm[i].signImg,
                  hitaskList[j].ASSIGNEE_,
                  hitaskList[j].eUrl
                );
              }
            }
          }
        }

        this.dialogVisible = true;
      });
    },

    // 给办理提交函数提供接口，并返回信息
    do_submit(data) {
      wfHttp.postHandleTasks(data).then((res) => {
        if (res && res.code === 200) {
          this.$message.success("发送成功");
          // 刷新待办任务列表
          this.checkData = [];
          this.dialogVisible = false;
          this.refreshCheckTask();
        } else {
          this.$message.error("发送失败");
        }
      });
    },
    // 办理结束
    do_end(data) {
      wfHttp.postHandleTasks(data).then((res) => {
        if (res && res.code === 200) {
          this.$message.success("结束成功");
          this.closeModal(); // 结束父组件对话框
          this.refreshCheckTask(); // 待办列表刷新
          // 刷新待办任务列表
        } else {
          this.$message.error("结束失败");
        }
      });
    },

    //  发送按钮触发函数
    sendTask(data) {
      console.log("选择好的下一步办理人数据::::", data);
      console.log("111111111111111111111111111");
      this.dataTemp = data;
      let singleFormData = data;
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("msg", "yes");
      //判断走流程还是走修改
      // let singleFormData = new FormData();
      //  let singleFormData = data;
      //   singleFormData.append("ID_", this.storeId);
      //   singleFormData.append("msg", "yes");
      if (this.ACT_ID == "StockUT4") {
        console.log("22222222222222222222");

        this.updateSendTask(this.dataTemp);
        console.log("33333333333333333333333");
      } else {
        // 一次提交一条记录
        for (let i = 0; i < this.workflow_Array.length; i++) {
          if (this.duty_name == this.workflow_Array[i]) {
            // console.log("当前工作流的申请意见", this.workForm[i].desc);
            singleFormData.append("OPINION", this.workForm[i].desc);
            break;
          }
        }
        console.log("要提交的数据:::::", singleFormData);
        this.do_submit(singleFormData); // 提交
      }
      this.ShiFaShuLiang = false; //实发数量插槽
    },
    //! 更新接口
    updateSendTask(data) {
      console.log("选择好的下一步办理人数据::::", data);
      let singleFormData = data;
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("msg", "yes");
      console.log("this.storeId", this.storeId);
      this.updateArr = [];
      // let tijiaoDate=[];
      let warehouseoutside = [];
      let text_ = "";

      for (let i = 0; i < this.dataSource.length; i++) {
        let warehouseInside = {};
        let id_ = this.TableItemID_[i];
        console.log("this.TableItemID_", this.TableItemID_);
        console.log("this.TableItemID_[i]", this.TableItemID_[i]);
        let warehouseStockNotificationContentEntity = {
          id: parseInt(this.dataSource[i].id),
          actualQuantity: this.dataSource[i].actualQuantity,
        };
        text_ =
          this.dataSource[i].id +
          ";" +
          this.dataSource[i].depotNo +
          ";" +
          this.dataSource[i].depotName +
          ";" +
          this.dataSource[i].storageUnit +
          ";" +
          this.dataSource[i].inventorNo +
          ";" +
          this.dataSource[i].inventorName +
          ";" +
          this.dataSource[i].standardModel +
          ";" +
          this.dataSource[i].unit +
          ";" +
          this.dataSource[i].auxiliaryUnit +
          ";" +
          this.dataSource[i].applyNumber +
          ";" +
          this.dataSource[i].actualQuantity +
          ";" +
          this.dataSource[i].postType +
          ";" +
          this.dataSource[i].deliveryTime +
          ";" +
          this.dataSource[i].sourceNumber +
          ";" +
          this.dataSource[i].isGiveAway +
          ";" +
          this.dataSource[i].remarks;
        console.log("555555555555555");

        warehouseInside.id_ = id_;
        warehouseInside.warehouseStockNotificationContentEntity = warehouseStockNotificationContentEntity;
        warehouseInside.text_ = text_;
        warehouseoutside.push(warehouseInside);
      }

      let queryPath = "?processName=" + "备货通知流程";
      console.log("queryPath工作流修改接口", queryPath);
      console.log("要更新的数组::::", this.updateArr);

      wfHttp.updatechangeForm(queryPath, warehouseoutside).then((res) => {
        console.log("更新工作流打印res===========", res);
        if (res && res.code === 200) {
          for (let i = 0; i < this.workflow_Array.length; i++) {
            if (this.duty_name == this.workflow_Array[i]) {
              console.log("当前工作流的申请意见", this.workForm[i].desc);
              singleFormData.append("OPINION", this.workForm[i].desc);
              break;
            }
          }
          console.log("要提交的数据:::::", singleFormData);
          this.do_submit(singleFormData); // 提交
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    // 结束按钮
    endTask() {
      let singleFormData = new FormData();
      singleFormData.append("ID_", this.storeId);
      singleFormData.append("msg", "no");
      // 一次提交一条记录
      for (let i = 0; i < this.workflow_Array.length; i++) {
        if (this.duty_name == this.workflow_Array[i]) {
          singleFormData.append("OPINION", this.workForm[i].desc);
          break;
        }
      }
      console.log("要提交的数据:::::", singleFormData);
      this.do_end(singleFormData);
    },

    // -------------- tab 2 已办任务 ----------------------
    // 重新刷新已办任务列表
    // refreshFinishTask() {
    //   console.log("已办任务", this.$refs);
    //   this.$refs.finishingTask.finishTaskList();
    // },

    // 已办任务组件触发函数，点击详情触发
    finishCheck(record) {
      let PROC_INST_ID_ = record.PROC_INST_ID_; // 实例流程ID
      let FILENAME = record.FILENAME;
      let singleFormData = new FormData();
      singleFormData.append("PROC_INST_ID_", PROC_INST_ID_);
      singleFormData.append("FILENAME", FILENAME);

      wfHttp.postQueryHisInfo(singleFormData).then((res) => {
        if (res && res.code === 200) {
          console.log("已办任务列表+++++++++++", res);

          let varList = res.result.varList; // 申请人提交的数据
          let hitaskList = res.result.hitaskList; // 工作流产生数据
          console.log("申请人提交数据:::", varList);
          console.log("工作流产生数据:::", hitaskList);

          // --------- 申请人数据 ---------------
          this.Form = {
            requisitionNo: varList[0].TEXT_, //申请单号
            depotName: varList[1].TEXT_, //仓库名称
            department: varList[2].TEXT_, //申请部门
            applicant: varList[5].TEXT_, //申请人
            kehu: varList[6].TEXT_, //客户
            salesman: varList[7].TEXT_, //业务员
            remarks: varList[8].TEXT_, //备注
            applicationDate: varList[12].TEXT_, //申请日期
          };
          if (varList[8].TEXT_ != "undefined") {
            this.Form[`remarks`] = varList[8].TEXT_;
          } else {
            this.Form[`remarks`] = "";
          }
          if (varList[6].TEXT_ != "undefined") {
            this.Form[`kehu`] = varList[6].TEXT_;
          } else {
            this.Form[`kehu`] = "";
          }

          this.dataSource = [];
          for (let m = 14, n = 1; m < varList.length; m++, n++) {
            let array = [];
            array = varList[m].TEXT_.split(";"); //
            console.log("点击已办后返回的数据为::::::", array);
            let dataSource2 = {
              key: n,
              id: array[0], //备货通知主键id
              depotNo: array[1], // 仓库编码
              depotName: array[2], // 仓库名称
              storageUnit: array[3], // 存储单位
              inventorNo: array[4], //存货编码
              inventorName: array[5], //存货名称
              standardModel: array[6], //规格型号
              unit: array[7], //单位
              auxiliaryUnit: array[8], //辅助单位
              applyNumber: array[9], //申请数量
              actualQuantity: array[10], //实发数量
              postType: array[11], //包装形式
              deliveryTime: array[12], //发货时间
              sourceNumber: array[13], // 源单号
              isGiveAway: array[14], //是否赠品
              remarks: array[15], //备注
            };

            if (array[6] != "null") {
              dataSource2[`standardModel`] = array[6];
            } else {
              dataSource2[`standardModel`] = "";
            }
            if (array[8] != "null") {
              dataSource2[`auxiliaryUnit`] = array[8];
            } else {
              dataSource2[`auxiliaryUnit`] = "";
            }
            if (array[10] != "null") {
              dataSource2[`actualQuantity`] = array[10];
            } else {
              dataSource2[`actualQuantity`] = "";
            }

            this.dataSource.push(dataSource2);
          }
          console.log("this.dataSource======>", this.dataSource);
          this.applicantName = hitaskList[1].ASSIGNEE_;
          this.applicantDate = hitaskList[1].START_TIME_;

          // --------- 工作流数据 ---------------
          // 利用for 循环来渲染数据,渲染的数据是目前已经完成的任务

          for (let j = 0; j < hitaskList.length; j++) {
            for (let i = 0; i < this.workflow_Array.length; i++) {
              if (hitaskList[j].ACT_NAME_ == this.workflow_Array[i]) {
                console.log(hitaskList[j].ACT_NAME_);
                this.workForm[i].desc = hitaskList[j].TEXT_; // 下一个描述
                if (hitaskList[j].END_TIME_ != null) {
                  this.workForm[i].date = hitaskList[j].END_TIME_.substring(
                    0,
                    10
                  );
                }
                this.workForm[i].signImg = this.getSignImg(hitaskList[j].eUrl);
                this.workForm[i].sign = this.showSignImg(
                  this.workForm[i].signImg,
                  hitaskList[j].ASSIGNEE_,
                  hitaskList[j].eUrl
                );
              }
            }
          }

          this.dialogVisible = true;
        } else {
          this.$message.error("服务器异常");
        }
      });
    },

    //  父组件对话框结束
    closeModal() {
      this.dialogVisible = false;
    },
  },
};
</script>

<style lang="less" scoped>
.list-content-item {
  color: rgba(0, 0, 0, 0.45);
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
  span {
    line-height: 20px;
  }
  p {
    margin: 4px 0 0;
    line-height: 22px;
  }
}
textarea {
  border: 0;
  border-radius: 5px;
  background-color: rgba(241, 241, 241, 0.98);
  width: 100%;
  height: 100px;
  padding: 10px;
  resize: none;
}
.tablehah {
  margin-top: 15px;
}
</style>
